package com.epomcloud.sso.modular.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.epomcloud.sso.modular.web.param.LoginParam;

/**
 * 传统项目单点登录(for web)
 * 
 * @author luopeng
 *
 */
@Controller
public class WebController {

    /**
     * 登录页面
     * 
     * @param model
     * @param request
     * @param response
     * @return
     */
    @GetMapping("login")
    public String login(Model model) {
        return "login";
    }

    /**
     * 登录
     * <p>
     * 如果登录,则重定向到单点客户端系统
     * <P>
     * 如果沒有登录,则重定向到登录页面
     * <p>
     * <a href="https://www.cnblogs.com/g-smile/p/9121335.html">关于重定向RedirectAttributes的用法<a/>
     * 
     * @param attributes
     * @param LoginParam
     * @return
     */
    @PostMapping("login")
    public String doLogin(RedirectAttributes attributes, Model model, LoginParam login) {
        return null;
    }

    /**
     * 退出登录
     * <p>
     * <a href="https://www.cnblogs.com/g-smile/p/9121335.html">关于重定向RedirectAttributes的用法<a/>
     * 
     * @param request
     * @param attributes
     * @return
     */
    @RequestMapping("logout")
    public String logout(HttpServletRequest request, HttpServletResponse response, RedirectAttributes attributes) {
        // 重定向到登录页面
        return "login";
    }
}